package com.hippo.api.file.factory;


import com.hippo.api.file.api.FileUploadApi;
import com.hippo.api.file.entity.FileDataEntity;
import com.hippo.common.base.model.ResponseDataModel;
import com.hippo.common.base.util.ResponseDataUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class FileUploadApiFallbackFactory implements FallbackFactory<FileUploadApi> {
    @Override
    public FileUploadApi create(Throwable cause) {
        log.error("文件上传服务调用失败:{}", cause.getMessage());
        cause.printStackTrace ();
        return new FileUploadApi() {
            @Override
            public ResponseDataModel updateFileDataByFileId(FileDataEntity fileDataEntity) {
                log.error("调用根据文件id修改文件信息失败:{}", cause.getMessage());
                return ResponseDataUtil.createResponseData(false,"根据文件id修改文件信息失败",null);
            }

            @Override
            public ResponseDataModel updateBusinessIdByBusinessId(FileDataEntity fileDataEntity) {
                log.error("调用根据业务id修改文件业务id失败:{}", cause.getMessage());
                return ResponseDataUtil.createResponseData(false,"根据业务id修改文件业务id失败",null);
            }
        };
    }
}
